home *** CD-ROM | disk | FTP | other *** search
- // Copyright (C) 1997-2002 Alias|Wavefront,
- // a division of Silicon Graphics Limited.
- //
- // The information in this file is provided for the exclusive use of the
- // licensees of Alias|Wavefront. Such users have the right to use, modify,
- // and incorporate this code into other products for purposes authorized
- // by the Alias|Wavefront license agreement, without fee.
- //
- // ALIAS|WAVEFRONT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- // INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- // EVENT SHALL ALIAS|WAVEFRONT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
- // CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
- // DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
- // TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- // PERFORMANCE OF THIS SOFTWARE.
- //
- // Alias|Wavefront Script File
- // MODIFY THIS AT YOUR OWN RISK
- //
- // Creation Date: 03 Apr 2000
- // Author: hmw
- //
- // Description:
- // Look at the shader connected to the input subdiv surface.
- // If if has no shader assigned then give it the default shader.
- // If it has a shader already, do nothing.
- //
- // Procedure Name:
- // subdAssignDefaultShader
- //
- // Input Arguments:
- // $subdiv: Subdiv shape to check for a shader.
- // If $subdiv is a transform, all subdiv shapes below it
- // will be processed.
- //
- // Return Value:
- // None.
- //
- global proc subdAssignDefaultShader( string $subdiv )
- {
- // Sometimes the results of the above command can
- // be transforms above the subds... Check all the
- // leaf-level subds for shaders.
- //
- string $subdivShapes[] = `ls -dag -lf -type subdiv $subdiv`;
-
- for( $subdiv in $subdivShapes ) {
-
- // Check for connections to "instObjGroups"
- // If any of the connections are a shading engine, then we're done
- //
- int $foundShadingGroup = false ;
- string $connections[] = `listConnections ($subdiv +
- ".instObjGroups")`;
- if( size($connections) == 0 ) {
-
- // Check further for connections to "instObjGroups[].objectGroups"
- //
- int $attrSize = `getAttr -size ($subdiv + ".instObjGroups")`;
- int $i;
- for( $i = 0; $i < $attrSize ; $i ++ ) {
- $connections = `listConnections ($subdiv +
- ".instObjGroups[" + $i + "].objectGroups")`;
-
- for( $connection in $connections ) {
- if( `nodeType $connection` == "shadingEngine" ) {
- $foundShadingGroup = true;
- break;
- }
- }
- if( $foundShadingGroup ) break;
- }
-
- } else {
-
- for( $connection in $connections ) {
- if( `nodeType $connection` == "shadingEngine" ) {
- $foundShadingGroup = true;
- break;
- }
- }
- }
-
- if( !$foundShadingGroup ) {
- sets -edit -fe initialShadingGroup $subdiv;
- }
- }
- }
-